<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

use think\Db;
use think\facade\Session;
//错误码定义
define('ErrCode_Normal', 0000);
define('ErrCode_Distance', 0001);
define('ErrCode_Maintain', 0002);
define('ErrCode_Dialog', 3000);
define('ErrCode_Toast', 3001);
define('ErrCode_Sign', 3002);
define('ErrCode_Other', 3003);
//错误提示语定义
define('ErrMsg_Normal', '正常');
define('ErrMsg_Distance', '该账号已下线或异地登录');
define('ErrMsg_Maintain', '系统维护中');
define('ErrMsg_Dialog', '弹窗错误');
define('ErrMsg_Toast', 'Toast错误');
define('ErrMsg_Sign', '校验数据错误');
define('ErrMsg_Other', '其他错误');
define('ErrMsg_Sys', '系统繁忙，请稍后再试！');
//权限定义
define('Level_SuperAdmin', 1);  //超级管理员
define('Level_Admin', 3);   //管理员
define('Level_CRMUser', 2);   //CRM用户



function mb_OutMessage($code, $msg, $data = array(), $count = null)
{
    $send = array(
        'code' => $code,
        'msg' => $msg,
        'data' => $data
    );

    if ($count != null) $send['count'] = $count;

    echo json_encode($send);
    exit();
}

function mb_CheckIsLogin()
{
    $token = Session::get('token');
    $userData = Db::table('user')->where('token', $token)->find();
    if ($userData == null) {
        mb_OutMessage(ErrCode_Distance, '您尚未登录！', '');
    }
    return $userData;
}

class RetData{
    public $m_Result;
    public $m_Data;
    public $m_Message;
    public $m_Count;
}